package org.nidy.erp.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.nidy.erp.mapper.IProduceMapper;
import org.nidy.erp.pojo.ProduceSorting;
import org.nidy.erp.service.IProduceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ProduceService implements IProduceService {
    @Autowired
    private IProduceMapper produceMapper;
    @Override
    public ProduceSorting getProduceSortingBoxNum(ProduceSorting produceSorting) {

        ProduceSorting boxNum = produceMapper.getBoxNum(produceSorting);
        if (boxNum.getSortingNum() != null) {
            boxNum.setExistsEmptyBox(true);
            return new ProduceSorting(boxNum.getDataID(), boxNum.getLinePrdID(), boxNum.getBarCode(), boxNum.getSortingType(), boxNum.getSortingNum(), boxNum.getIsOccupied(), boxNum.getIsIntoBox(), boxNum.getExistsEmptyBox());
        } else {
            if (produceMapper.IsExistsEmptyBox()){
                boxNum.setExistsEmptyBox(false);
                return new ProduceSorting(boxNum.getDataID(), boxNum.getLinePrdID(), boxNum.getBarCode(), boxNum.getSortingType(), boxNum.getSortingNum(), boxNum.getIsOccupied(), boxNum.getIsIntoBox(), boxNum.getExistsEmptyBox());
            }

            return null;
        }
    }
}
